orig = 1

call split orig

procedure split .orig
.i = 1
for .s from 0 to 1
	if .s = 0
		.sex$ = "m"
	else
		.sex$ = "f"
	endif

	for .type from 0 to 1

		for .sh from 0 to 2
			.sourceHZ = 100 + .sh*100
			
			#for .b from 0 to 2
				.bandwidth = 0.11

				for .m from 0 to 2
					.maxfreq = 4500 + .m*500
					call filter .orig '.sex$' .type .sourceHZ .maxfreq .bandwidth
					.res[.i] = filter.res
					.i = .i+1
				endfor
			#endfor
		endfor
	endfor
endfor

	# drawing fixed soure, type var maxfreq
	for .j from 0 to (.i/3)-1
		Erase all
		.sel = 1 + .j*3
		select .res[.sel]
		Black
		Scatter plot... F2in 2500 400 F1in 1100 200 IPA 12 yes
		plus split.res[.sel+1]
		plus split.res[.sel+2]
		Red
		Scatter plot... F2b 2500 400 F1b 1100 200 IPA 12 no
		Green
		Scatter plot... F2r 2500 400 F1r 1100 200 IPA 12 no
		Save as EPS file... /home/xtroce/tmp/varmaxfreq'.sel'.eps
	endfor
endproc

procedure filter .orig .sex$ .type .source .maxfreq .bandwidth
	select .orig
	tmp[0] = Extract rows where column (text)... Sex "is equal to" '.sex$'
	tmp[1] = Extract rows where column (number)... Type "equal to" .type
	tmp[2] = Extract rows where column (number)... SourceHz "equal to" .source
	tmp[3] = Extract rows where column (number)... Bandwidth "equal to" .bandwidth
	.res = Extract rows where column (number)... MaxFreq "equal to" .maxfreq
	select tmp[0]
	plus tmp[1]
	plus tmp[2]
	plus tmp[3]
	Remove
endproc
